package com.dongwu;


import java.util.List;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.dongwu.manager.entity.AppVersion;
import com.dongwu.manager.entity.Product;
import com.dongwu.manager.service.AppVersionService;
import com.dongwu.manager.service.ProductService;

public class imgToOss extends DongwuMicroManagementApplicationTests{
	@Autowired
	private ProductService productService;
	@Autowired
	private AppVersionService appVersionService;
	
	@Test
	public void appversion() {
		List<AppVersion> a= appVersionService.findAll();
		for (AppVersion appVersion : a) {
			if(appVersion.getDownUrl()!= null){
				appVersion.setDownUrl(appVersion.getDownUrl().replace("http://120.78.153.204:8089", "http://gtq.oss-cn-hangzhou.aliyuncs.com"));
			}
		}
		appVersionService.batchUpdate(a);
	}
	@Test
	public void product() {
		List<Product> a= productService.findAll();
		for (Product product : a) {
			if(product.getImage()!=null){
				product.setImage(product.getImage().replace("http://120.78.153.204:8089", "http://gtq.oss-cn-hangzhou.aliyuncs.com"));
			}
			if(product.getIntroduction()!=null){
				product.setIntroduction(product.getIntroduction().replace("http://120.78.153.204:8089", "http://gtq.oss-cn-hangzhou.aliyuncs.com"));
			}
			if(product.getSlideImage()!=null){
				product.setSlideImage(product.getSlideImage().replace("http://120.78.153.204:8089", "http://gtq.oss-cn-hangzhou.aliyuncs.com"));
			}
			if(product.getVideo()!=null){
				product.setVideo(product.getVideo().replace("http://120.78.153.204:8089", "http://gtq.oss-cn-hangzhou.aliyuncs.com"));
			}
		}
		productService.batchUpdate(a);
	}

}
